﻿using ICMS.PluginInterfaces;
using commonImportPlugin.FilesCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using commonImportPlugin.Config;
using commonImportPlugin.Common;
using commonImportPlugin.FilesCore.PbocFile;
using commonImportPlugin.Configs.PbocFile;

namespace commonImportPlugin.Factorys
{
    //
    //  抽象工厂
    //
    #region
    /// <summary>
    /// 金融抽象工厂
    /// </summary>
    public abstract class AbstractPbocFile
    {
        public abstract PbocFileCore CreatePbocFileCore(params object[] list);
    }
    /// <summary>
    /// 金融工厂
    /// </summary>
    public abstract class PbocFileCore
    {
        /// <summary>
        /// 获取所有金融数据
        /// </summary>
        public abstract List<ICData> GetPbocAllDatas(List<string> pbocFilePaths, out int pbocCounts);
        /// <summary>
        /// 检查金融数据
        /// </summary>
        public abstract bool CheckData(ICData pbocIcData, string IcDataRegexs, string TrackDataRegex, string BankCardIdRegexs, string PersonIdRegexs);
        /// <summary>
        /// 获取所有金融数据量
        /// </summary>
        public abstract int GetPbocAllCounts(List<string> pbocFilePaths);
    }
    #endregion

    //
    //  工厂集
    //
    #region
    /// <summary>
    /// 普通模式金融处理工厂（金融数据文件以二进制存放，不涉及数据加解密)
    /// </summary>
    public class PbocFileCoreFactory : AbstractPbocFile
    {
        public override PbocFileCore CreatePbocFileCore(params object[] list)
        {
            PbocFileCoreClass core=new PbocFileCoreClass();
            return core.GetInstance();
        }
    }
    /// <summary>
    /// 行为单位模式金融处理工厂（金融数据文件内容以行为单位存放)
    /// </summary>
    public class PbocFileCoreJHFactory : AbstractPbocFile
    {
        public override PbocFileCore CreatePbocFileCore(params object[] list)
        {
            PbocFileCoreJHClass core = new PbocFileCoreJHClass();
            return core.getInstance();
        }
    }
    #endregion

    //
    //  简单工厂
    //
    #region

    /// <summary>
    /// 金融简单工厂
    /// </summary>
    public class setPbocFileCoreFactory
    {
        public PbocFileCore CreateFactory(string whichFactory) 
        {
            switch (whichFactory)
            {               
                case "General"://普通模式
                    //初始化配置
                    PbocFileConfig pbocFileConfig = new PbocFileConfig();
                    pbocFileConfig.Init();
                    //返回初始化核心
                    return new PbocFileCoreFactory().CreatePbocFileCore();
                case "JSYH"://建行模式
                    //初始化配置
                    PbocFileConfigJH pbocFileConfigJH = new PbocFileConfigJH();
                    pbocFileConfigJH.Init();
                    //返回初始化核心
                    return new PbocFileCoreJHFactory().CreatePbocFileCore();
                default:
                    break;
            }
            throw new Exception("工厂配置" + whichFactory+"不存在，请检查！");
        }
    }
    #endregion
}